//
//  HomePageViewController.m
//  A_Comic
//
//  Created by sos on 16/1/16.
//  Copyright © 2016年 sos. All rights reserved.
//

#import "HomePageViewController.h"
#import <AFNetworking.h>
#import "HomePageModel.h"
#import "HomePageTableViewCell.h"
#import <UIImageView+WebCache.h>
#import "LunBoHomePageModel.h"
#import "Lunbo.h"
#import "MoreViewController.h"
#import "WuLiangCollectionViewCell.h"
#import "UpDateCollectionViewCell.h"
#import "TopCollectionViewCell.h"
#import "DetailsViewController.h"
#import "MoreDanMuViewController.h"
#import <MJRefresh.h>
@interface HomePageViewController ()<UITableViewDataSource,UITableViewDelegate,UICollectionViewDataSource,UICollectionViewDelegate>
@property (nonatomic,retain) UITableView *tableView;//整个页面是一个tableView
@property (nonatomic,retain) NSMutableArray *wuDataArr; //无良数组
@property (nonatomic,retain) NSMutableArray *lunBoDataArr;//轮播图数组
@property (nonatomic,retain) NSMutableArray *upDatedataArr;//今日更新数组
@property (nonatomic,retain) NSMutableArray *danMuDataArr;//弹幕的数组
@property (nonatomic,retain) NSMutableArray *riMuDataArr;//日漫经典 数组
@property (nonatomic,retain) NSMutableArray *dataArrFir;//新作上线
@property (nonatomic,retain) NSMutableArray *topDataArr;//页码尾部top数组
@property (nonatomic,retain) UICollectionView *collectionView;//无良推荐布局
@property (nonatomic,retain) UICollectionView *dayToDaycollectionView;//今日更新布局
@property (nonatomic,retain) UICollectionView *riManCollectionView;//日漫经典布局
@property (nonatomic,retain) UICollectionView *xinZuoCollectionView;//新作上线布局
@property (nonatomic,retain) UICollectionView *topCollectionView;//页码尾部top布局
@property (nonatomic,retain) NSNumber *wuMoreNumber;//更多数据 无良推荐
@property (nonatomic,retain) NSNumber *upMoreNumber;//更多数据 今日更新
@property (nonatomic,retain) NSNumber *rimanNumber;//更多数据 日漫
@property (nonatomic,retain) NSNumber *xinzuoNumber;//更多数据 新作上线

@end

@implementation HomePageViewController
-(void)dealloc
{
    [_tableView release];
    [_wuDataArr release];
    [_lunBoDataArr release];
    [_upDatedataArr release];
    [_danMuDataArr release];
    [_riMuDataArr release];
    [_topDataArr release];
    [_dataArrFir release];
    [_topCollectionView release];
    [_xinZuoCollectionView release];
    [_riManCollectionView release];
    [_dayToDaycollectionView release];
    [_collectionView release];
    [_wuMoreNumber release];
    [_upMoreNumber release];
    [_rimanNumber release];
    [_xinzuoNumber release];
    [super dealloc];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
//    self.navigationController.automaticallyAdjustsScrollViewInsets = NO;
    // Do any additional setup after loading the view.
    

    
    //取消边界自适应
    self.automaticallyAdjustsScrollViewInsets = NO;
    //在导航栏上 加入透明图片
//    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"clear_nav.png"] forBarMetrics:UIBarMetricsDefault];
//    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    

    

    self.navigationController.navigationBarHidden = YES;


  //整个页面是一个tableView 创建tableView
    CGRect f = self.view.frame;
    f.size.height = self.view.frame.size.height-49;
    self.tableView = [[UITableView alloc] initWithFrame:f style:UITableViewStylePlain];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
    //注册
    [self.tableView registerClass:[HomePageTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.tableView release];
    
    //数据处理
    [self data];
    
    
    //设置tableView头高
    UIView *header = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 900)];
    header.tag = 10001;
//    header.backgroundColor = [UIColor yellowColor];
    self.tableView.tableHeaderView = header;
    
    [header release];
    
    
    
    
   // 创建collectionView 放在tableView头高处
    //
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc]init];
    //设置水平滑动
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layout.itemSize = CGSizeMake((self.view.bounds.size.width - 40)/3, 150);
    layout.minimumInteritemSpacing =5;
    layout.minimumLineSpacing = 10;
    layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 250, header.frame.size.width, 180) collectionViewLayout:layout];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    
    self.collectionView.backgroundColor = [UIColor whiteColor];
    
    [self.collectionView registerClass:[WuLiangCollectionViewCell class] forCellWithReuseIdentifier:@"cellOne"];

    [header addSubview:self.collectionView];
    [layout release];
    [self.collectionView release];
    
    // 无良推荐
    UILabel *WuLiangName = [[UILabel alloc]initWithFrame:CGRectMake(10,200, header.frame.size.width/4, 50)];
//    WuLiangName.backgroundColor = [UIColor blueColor];
    WuLiangName.text = @"精品推荐";
    [header addSubview:WuLiangName];
    [WuLiangName release];
    
    //按钮 无良推荐
    UIButton *wuButton = [UIButton buttonWithType:UIButtonTypeCustom];
    wuButton.frame = CGRectMake(header.frame.size.width-WuLiangName.frame.size.width-10, WuLiangName.frame.origin.y, WuLiangName.frame.size.width, WuLiangName.frame.size.height);
    wuButton.tag = 1000;
//    wuButton.backgroundColor = [UIColor redColor];
    [wuButton setTitle:@"更多" forState:UIControlStateNormal];
    [wuButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    //加入按钮点击方法
    [wuButton addTarget:self action:@selector(gengduo:) forControlEvents:UIControlEventTouchUpInside];
    [header addSubview:wuButton];
    
    
    //今日我更新
    UILabel *upName = [[UILabel alloc]initWithFrame:CGRectMake(WuLiangName.frame.origin.x, self.collectionView.frame.origin.y+self.collectionView.frame.size.height +10, WuLiangName.frame.size.width, WuLiangName.frame.size.height)];
    
//    upName.backgroundColor = [UIColor greenColor];
    upName.text = @"今日我更新";
    [header addSubview:upName];
    [upName release];
    
    //按钮
    UIButton *upButton = [UIButton buttonWithType:UIButtonTypeCustom];
    upButton.frame = CGRectMake(header.frame.size.width-upName.frame.size.width-10, upName.frame.origin.y, upName.frame.size.width, upName.frame.size.height);
    upButton.tag = 2000;
//    upButton.backgroundColor = [UIColor redColor];
    [upButton setTitle:@"更多" forState:UIControlStateNormal];
    [upButton addTarget:self action:@selector(gengduo:) forControlEvents:UIControlEventTouchUpInside];
    [upButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [header addSubview:upButton];

    

    
    //今日我更新 collectionView
    
    UICollectionViewFlowLayout *layoutOne = [[UICollectionViewFlowLayout alloc]init];
    layoutOne.minimumInteritemSpacing = 10;
    layoutOne.minimumLineSpacing = 10;
    layoutOne.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    layoutOne.itemSize = CGSizeMake(self.view.frame.size.width-20,100);
    
    
    
    self.dayToDaycollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(upName.frame.origin.x, upName.frame.origin.y+upName.frame.size.height, self.view.bounds.size.width, 340) collectionViewLayout:layoutOne];
    self.dayToDaycollectionView.delegate = self;
    self.dayToDaycollectionView.dataSource = self;
    self.dayToDaycollectionView.backgroundColor = [UIColor whiteColor];
    [header addSubview:self.dayToDaycollectionView];

    [self.dayToDaycollectionView release];
    [layoutOne release];
    [self.dayToDaycollectionView registerClass:[UpDateCollectionViewCell class] forCellWithReuseIdentifier:@"newCell"];
    
    
    // 每日一推
    UILabel *dayName = [[UILabel alloc]initWithFrame:CGRectMake(self.dayToDaycollectionView.frame.origin.x , self.dayToDaycollectionView.frame.origin.y+self.dayToDaycollectionView.frame.size.height+20, upName.frame.size.width, upName.frame.size.height)];
//    dayName.backgroundColor = [UIColor redColor];
    dayName.text = @"弹幕君来袭";
    [header addSubview:dayName];
    [dayName release];
    
    UIButton *dayButton = [UIButton buttonWithType:UIButtonTypeCustom];
    dayButton.frame = CGRectMake(upButton.frame.origin.x, dayName.frame.origin.y, upButton.frame.size.width, upButton.frame.size.height);
//    dayButton.backgroundColor = [UIColor greenColor];
    [dayButton setTitle:@"更多" forState:UIControlStateNormal];
    [dayButton addTarget:self action:@selector(danMuGengDuo) forControlEvents:UIControlEventTouchUpInside];
    [dayButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [header addSubview:dayButton];
    
    
    
    //脚高
    
    
    UIView *foot = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 1160)];
    
//    foot.backgroundColor = [UIColor yellowColor];
    self.tableView.tableFooterView = foot;
    
    [foot release];
    
    //日漫经典
    UILabel *rimanlabel = [[UILabel alloc]initWithFrame:CGRectMake(dayName.frame.origin.x, 0, dayName.frame.size.width, dayName.frame.size.height)];
    
//    rimanlabel.backgroundColor = [UIColor brownColor];
    rimanlabel.text = @"日漫经典";
    [foot addSubview:rimanlabel];
    [rimanlabel release];
    
    //按钮
    UIButton *rimanButton = [UIButton buttonWithType:UIButtonTypeCustom];
    rimanButton.frame = CGRectMake(dayButton.frame.origin.x, rimanlabel.frame.origin.y, dayButton.frame.size.width, dayButton.frame.size.height);
    rimanButton.tag = 3000;
    [rimanButton setTitle:@"更多" forState:UIControlStateNormal];
    [rimanButton addTarget:self action:@selector(gengduo:) forControlEvents:UIControlEventTouchUpInside];
    [rimanButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [foot addSubview:rimanButton];
    
    
    
    
    
    
    
    UICollectionViewFlowLayout *layoutTwo = [[UICollectionViewFlowLayout alloc]init];
    layoutTwo.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layoutTwo.itemSize = CGSizeMake((self.view.bounds.size.width - 40)/3, 150);
    layoutTwo.minimumInteritemSpacing =5;
    layoutTwo.minimumLineSpacing = 10;
    layoutTwo.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    
    
    self.riManCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, rimanlabel.frame.size.height, foot.frame.size.width, 180) collectionViewLayout:layoutTwo];
    self.riManCollectionView.delegate = self;
    self.riManCollectionView.dataSource = self;
    self.riManCollectionView.backgroundColor = [UIColor whiteColor];
    [foot addSubview:self.riManCollectionView];
    [self.riManCollectionView release];
    [layoutTwo release];
    [self.riManCollectionView registerClass:[WuLiangCollectionViewCell class] forCellWithReuseIdentifier:@"cellThree"];
    
    
    
   //新作上线
    
    UILabel *xinzuoLabel = [[UILabel alloc]initWithFrame:CGRectMake(rimanlabel.frame.origin.x, self.riManCollectionView.frame.origin.y+self.riManCollectionView.frame.size.height, rimanlabel.frame.size.width, rimanlabel.frame.size.height)];
//    xinzuoLabel.backgroundColor = [UIColor grayColor];
    xinzuoLabel.text = @"新作上线";
    [foot addSubview:xinzuoLabel];
    [xinzuoLabel release];
    
    
    UIButton *xinzuoButton = [UIButton buttonWithType:UIButtonTypeCustom];
    xinzuoButton.frame = CGRectMake(rimanButton.frame.origin.x, xinzuoLabel.frame.origin.y, rimanButton.frame.size.width, rimanButton.frame.size.height);
    xinzuoButton.tag = 4000;
    [xinzuoButton setTitle:@"更多" forState:UIControlStateNormal];
    [xinzuoButton addTarget:self action:@selector(gengduo:) forControlEvents:UIControlEventTouchUpInside];
    [xinzuoButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [foot addSubview:xinzuoButton];
    
    
    UICollectionViewFlowLayout *layoutThree = [[UICollectionViewFlowLayout alloc]init];
    layoutThree.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layoutThree.itemSize = CGSizeMake((self.view.bounds.size.width - 40)/3, 150);
    layoutThree.minimumInteritemSpacing =5;
    layoutThree.minimumLineSpacing = 10;
    layoutThree.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    
    
    self.xinZuoCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,xinzuoLabel.frame.origin.y+xinzuoLabel.frame.size.height, foot.frame.size.width, 180) collectionViewLayout:layoutThree];
    self.xinZuoCollectionView.delegate = self;
    self.xinZuoCollectionView.dataSource = self;
    self.xinZuoCollectionView.backgroundColor = [UIColor whiteColor];
    [foot addSubview:self.xinZuoCollectionView];
    [self.xinZuoCollectionView release];
    [layoutThree release];
    [self.xinZuoCollectionView registerClass:[WuLiangCollectionViewCell class] forCellWithReuseIdentifier:@"cellFour"];
    
    
    // 排行图片
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.xinZuoCollectionView.frame.origin.y+self.xinZuoCollectionView.frame.size.height, self.view.frame.size.width, 100)];
//    image.backgroundColor = [UIColor orangeColor];
    
    [foot addSubview:image];
    [image release];
    
    
    //排行 collectionView
    
    
    UICollectionViewFlowLayout *layoutFour = [[UICollectionViewFlowLayout alloc]init];
    layoutFour.minimumInteritemSpacing = 10;
    layoutFour.minimumLineSpacing = 10;
    layoutFour.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    layoutFour.itemSize = CGSizeMake(self.view.frame.size.width-20,(600-40-20)/5);
    
    
    
    
    self.topCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(self.xinZuoCollectionView.frame.origin.x, image.frame.origin.y+image.frame.size.height, self.xinZuoCollectionView.frame.size.width, 600) collectionViewLayout:layoutFour];
    self.topCollectionView.delegate = self;
    self.topCollectionView.dataSource = self;
    self.topCollectionView.backgroundColor = [UIColor whiteColor];
    [foot addSubview:self.topCollectionView];
    
    [self.topCollectionView registerClass:[TopCollectionViewCell class] forCellWithReuseIdentifier:@"cellFir"];
    [self.topCollectionView release];
    [layoutFour release];
    
    
    
    
    

    

    
    
    
    
}

//弹幕君更多点击方法
-(void)danMuGengDuo
{
    MoreDanMuViewController *more = [[MoreDanMuViewController alloc]init];
    
    [self.navigationController pushViewController:more animated:YES];
    [more release];
    
}
//其他更多点击方法
-(void)gengduo:(UIButton *)btn
{
    
    MoreViewController *more = [[MoreViewController alloc]init];
    
    if (btn == [self.view viewWithTag:1000]) {
        
        more.str = self.wuMoreNumber.stringValue;
    }else if (btn == [self.view viewWithTag:2000]){
        more.str = self.upMoreNumber.stringValue;
        
        
    }else if (btn == [self.view viewWithTag:3000]){
        
        more.str = self.rimanNumber.stringValue;
    }else if (btn == [self.view viewWithTag:4000]){
        more.str = self.xinzuoNumber.stringValue;
        
    }
    
    [self.navigationController pushViewController:more animated:YES];
    
}

//数据处理
-(void)data
{
    NSString *url = @"http://mobilev3.ac.qq.com/Home/homePageDetailForIosV3/uin/0/local_version/3.5.1/channel/1001/guest_id/FBB11919-34E9-4168-9491-811B4C0BDBD6";


//    [YZCAFNetwork getUrl:url body:nil response:YZCJSON requestHeadFile:nil success:^(NSURLSessionDataTask *task, id resposeObject) {
//        NSLog(@"%@",resposeObject);
//        
//    } failure:^(NSURLSessionDataTask *task, NSError *error) {
//        
//        
//    }];
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
    [manager GET:url parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
//        NSLog(@"~~%@",responseObject);
        //无良数据
        self.wuDataArr = [NSMutableArray array];
        //轮播图数据
        self.lunBoDataArr = [NSMutableArray array];
        //今日更新数据
        self.upDatedataArr = [NSMutableArray array];
        //弹幕的数据
        self.danMuDataArr = [NSMutableArray array];
        //日漫经典数据
        self.riMuDataArr = [NSMutableArray array];
        //新作上线数据
        self.dataArrFir = [NSMutableArray array];
        
        self.topDataArr = [NSMutableArray array];
        //无良临时数据数组
        NSArray *wuArr = responseObject[@"data"][@"comicList1"][@"data"];
        self.wuMoreNumber = responseObject[@"data"][@"comicList1"][@"comic_list_id"];
        
        NSArray *lunBoArr = responseObject[@"data"][@"banner"][@"data"];
        //今日我更新临时数据数组
        NSArray *arrTwo = responseObject[@"data"][@"comicList3"][@"data"];
        self.upMoreNumber = responseObject[@"data"][@"comicList3"][@"comic_list_id"];
        NSArray *arrThiree = responseObject[@"data"][@"lightComic"][@"data"];
        
        //日漫经典临时数据数组
        NSArray *arrFour = responseObject[@"data"][@"manga"][@"data"];
        self.rimanNumber = responseObject[@"data"][@"manga"][@"comic_list_id"];
        
        //新作上线临时数组
        NSArray *arrFir = responseObject[@"data"][@"comicList5"][@"data"];
        self.xinzuoNumber = responseObject[@"data"][@"comicList5"][@"comic_list_id"];
        
        NSArray *arrSix = responseObject[@"data"][@"top"][@"data"];
        //无良 数据
        self.wuDataArr = [HomePageModel modelHandlerWithArray:wuArr];

        [self.collectionView reloadData];
        
        
        
        
        //轮播图数据
        for (NSDictionary *dic in lunBoArr) {
            LunBoHomePageModel *m = [[LunBoHomePageModel alloc]init];
            [m setValuesForKeysWithDictionary:dic];
            [self.lunBoDataArr addObject:m.banner_url];
            [m release];
            [self.tableView reloadData];
//            NSLog(@"%@",self.dataArr1);
            
        }

        //设置轮播图
        UIView *a = [self.view viewWithTag:10001];
        CGRect f = a.frame;
        f.size.height = 200;
        Lunbo *b = [[Lunbo alloc] initWithFrame:f stringArray:self.lunBoDataArr];
        
        
        [a addSubview:b];
        [b release];
        
        
//今日更新数据
        
        for (NSInteger i = 0; i < 3; i++) {
            NSDictionary *dic = arrTwo[i];
            HomePageModel *m = [[HomePageModel alloc]init];
            [m setValuesForKeysWithDictionary:dic];
            [self.upDatedataArr addObject:m];
            [m release];
            [self.dayToDaycollectionView reloadData];
        }
    
        //弹幕君栏

        self.danMuDataArr = [HomePageModel modelHandlerWithArray:arrThiree];
        [self.tableView reloadData];
        //日漫经典 数据

        self.riMuDataArr = [HomePageModel modelHandlerWithArray:arrFour];
        [self.riManCollectionView reloadData];
        
        //新作上线
        

        self.dataArrFir = [HomePageModel modelHandlerWithArray:arrFir];
        [self.xinZuoCollectionView reloadData];
        
        //top排行数据
        

        self.topDataArr = [HomePageModel modelHandlerWithArray:arrSix];
        [self.topCollectionView reloadData];
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        NSLog(@"%@",error);
    }];
    
    
    
    
    
}
//tableView协议方法
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.danMuDataArr.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HomePageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    HomePageModel *m = self.danMuDataArr[indexPath.row];
    [cell.img sd_setImageWithURL:[NSURL URLWithString:m.img_url]];
    cell.labelOne.text = m.title;
//    cell.label1.numberOfLines = 1;
//    [cell.label1 sizeToFit];
    cell.labelTwo.text = [NSString stringWithFormat:@"作者:%@",m.artist_name];
//    [cell.label2 sizeToFit];
    return cell;
}

//cell高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 200;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//tableView点击
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    HomePageModel *m = self.danMuDataArr[indexPath.row];
    UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:m.special_event_url]]];
    NSLog(@"%@",m.special_event_url);
    self.tabBarController.tabBar.hidden = YES;
    [self.view addSubview:webView];
    [webView release];
    
    
    
    
    
    
}
//collectionView协议方法
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    
    //判断点击的是那个collection
    if (collectionView == self.collectionView) {
        
        return self.wuDataArr.count;
    }else if (collectionView == self.dayToDaycollectionView){
        
        return self.upDatedataArr.count;
    }else if (collectionView == self.riManCollectionView){
        
        return self.riMuDataArr.count;
    }else if (collectionView == self.xinZuoCollectionView){
        return self.dataArrFir.count;
    }else if (collectionView == self.topCollectionView){
        return self.topDataArr.count;
    }else{
        return 0;
    }
    
    
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    

    //根据判断 进行不同collection 的赋值
    if (collectionView == self.collectionView) {
        
        WuLiangCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellOne" forIndexPath:indexPath];
        
        
        HomePageModel *m = self.wuDataArr[indexPath.item];

        [cell.imgView sd_setImageWithURL:[NSURL URLWithString:m.cover_url]];

        cell.labelOne.text = m.title;
        cell.labelTwo.text = m.meta_info;
//        cell.backgroundColor = [UIColor blueColor];
        return cell;
    }else if (collectionView == self.dayToDaycollectionView){
    
    
        UpDateCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"newCell" forIndexPath:indexPath];
    HomePageModel *m = self.upDatedataArr[indexPath.item];
//        cell.backgroundColor = [UIColor blueColor];
    [cell.img sd_setImageWithURL:[NSURL URLWithString:m.cover_url]];
    cell.labelOne.text = m.title;
    cell.labelTwo.text = m.artist_name;
    cell.labelThree.text = m.meta_info;
        return cell;
    
    }else if (collectionView == self.riManCollectionView){
        WuLiangCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellThree" forIndexPath:indexPath];
        HomePageModel *m = self.riMuDataArr[indexPath.item];
        
        [cell.imgView sd_setImageWithURL:[NSURL URLWithString:m.cover_url]];
        cell.labelOne.text = m.title;
        cell.labelTwo.text = m.meta_info;
        return cell;
        
    }else if (collectionView == self.xinZuoCollectionView){

        WuLiangCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellFour" forIndexPath:indexPath];
        HomePageModel *m = self.dataArrFir[indexPath.item];
        
        [cell.imgView sd_setImageWithURL:[NSURL URLWithString:m.cover_url]];
        cell.labelOne.text = m.title;
        cell.labelTwo.text = m.meta_info;
        return cell;
        
    }else if(collectionView == self.topCollectionView){
        TopCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellFir" forIndexPath:indexPath];
        
        HomePageModel *m = self.topDataArr[indexPath.item];
        
        [cell.img sd_setImageWithURL:[NSURL URLWithString:m.cover_url]];
        cell.labelOne.text = m.title;
        cell.labelTwo.text = m.type;
        NSInteger i = indexPath.item+1;
//        NSString *str = (NSString *)i;
        cell.labelThree.text = [NSString stringWithFormat:@"%ld",(long)i];
        
        
        return cell;
    }else{
        return nil;
    }
    
}
//collectionView点击方法
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    DetailsViewController *deta = [[DetailsViewController alloc]init];

  

    if (collectionView == self.collectionView) {
        
        deta.m = self.wuDataArr[indexPath.item];
//        [self.navigationController pushViewController:deta animated:YES];
//        
//        [deta release];
    }else if (collectionView == self.dayToDaycollectionView){
        deta.m = self.upDatedataArr[indexPath.item];
//        [self.navigationController pushViewController:deta animated:YES];
//        
//        [deta release];

    }else if (collectionView == self.riManCollectionView){
        deta.m = self.riMuDataArr[indexPath.item];
//        [self.navigationController pushViewController:deta animated:YES];
//        
//        [deta release];

    }else if (collectionView == self.xinZuoCollectionView){
        deta.m = self.dataArrFir[indexPath.item];
//        [self.navigationController pushViewController:deta animated:YES];
//        
//        [deta release];
    }else if (collectionView == self.topCollectionView){
        deta.m = self.topDataArr[indexPath.item];
    }
    
    [self.navigationController pushViewController:deta animated:YES];
    
    [deta release];
    
    
    
    
    
    
    
    
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
    self.tabBarController.tabBar.hidden = NO;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
